﻿@model Eqwww.Web.Areas.SystemManage.Models.User.DetailsViewModel
@inject Eqwww.App.Identity.UserApp UserApp
@inject Eqwww.App.SystemManage.OrganizeApp OrganizeApp

@{
    ViewData["Title"] = "Details";
    Layout = "~/Views/Shared/_ManageFormLayout.cshtml";
}

<div class="mdui-container">
    <div class="mdui-row">
        <div class="mdui-col-xs-12 mdui-col-md-6">

            <div class="mdui-typo-title mdui-p-t-4">基本信息</div>
            <div class="mdui-list">
                <div class="mdui-list-item mdui-ripple">
                    <div class="mdui-list-item-content">
                        <div class="mdui-list-item-text">
                            @Html.DisplayNameFor(model => model.User.Avatar)
                        </div>
                        <div class="mdui-list-item-title">
                            <img class="mdui-img-circle" style="width:128px;" src="@Model.User.Avatar" />
                        </div>
                    </div>
                </div>

                <div class="mdui-list-item mdui-ripple">
                    <div class="mdui-list-item-content">
                        <div class="mdui-list-item-text">
                            用户名
                        </div>
                        <div class="mdui-list-item-title">
                            @Html.DisplayFor(model => model.User.UserName)
                        </div>
                    </div>
                </div>

                <div class="mdui-list-item mdui-ripple">
                    <div class="mdui-list-item-content">
                        <div class="mdui-list-item-text">
                            联系方式
                        </div>
                        <div class="mdui-list-item-title">
                            @Html.DisplayFor(model => model.User.Contact)
                        </div>
                    </div>
                </div>

                <div class="mdui-list-item mdui-ripple">
                    <div class="mdui-list-item-content">
                        <div class="mdui-list-item-text">
                            电子邮箱
                        </div>
                        <div class="mdui-list-item-title">
                            @Html.DisplayFor(model => model.User.Email)
                        </div>
                    </div>
                </div>

                <div class="mdui-list-item mdui-ripple">
                    <div class="mdui-list-item-content">
                        <div class="mdui-list-item-text">
                            系统账号标识
                        </div>
                        <div class="mdui-list-item-title">
                            @if (Model.User.IsSystem == true)
                            {

                                <span class="mdui-text-color-theme">是</span>
                            }
                            else
                            {
                                <span class="">否</span>
                            }
                        </div>
                    </div>
                </div>

                <div class="mdui-list-item mdui-ripple">
                    <div class="mdui-list-item-content">
                        <div class="mdui-list-item-text">
                            账号状态
                        </div>
                        <div class="mdui-list-item-title">
                            @if (Model.User.IsDisabled == true)
                            {

                                <span class="mdui-text-color-theme-accent">禁用</span>
                            }
                            else
                            {
                                <span class="mdui-text-color-theme">启用</span>
                            }
                        </div>
                    </div>
                </div>


                <div class="mdui-list-item mdui-ripple">
                    <div class="mdui-list-item-content">
                        <div class="mdui-list-item-text">
                            姓名
                        </div>
                        <div class="mdui-list-item-title">
                            @Html.DisplayFor(model => model.User.RealName)
                        </div>
                    </div>
                </div>

                <div class="mdui-list-item mdui-ripple">
                    <div class="mdui-list-item-content">
                        <div class="mdui-list-item-text">
                            岗位列表
                        </div>
                        @{
                            var myPosts = UserApp.GetPostsByPrincipal(Model.User.Id);
                            if (myPosts != null && myPosts.Count() > 0)
                            {
                                foreach (var item in myPosts)
                                {
                                    var completePath = OrganizeApp.GetAncestorNamesString(item.OrganizeId) + "/" + item.Name;
                                    <div class="mdui-list-item-title">
                                        @completePath
                                    </div>
                                }
                            }
                            else
                            {
                                <div class="mdui-list-item-title">
                                    <span class="mdui-text-color-theme-accent">未设置</span>
                                </div>
                            }
                        }

                    </div>

                </div>

                <div class="mdui-list-item mdui-ripple">
                    <div class="mdui-list-item-content">
                        <div class="mdui-list-item-text">
                            排序码
                        </div>
                        <div class="mdui-list-item-title">
                            @Html.DisplayFor(model => model.User.SortCode)
                        </div>
                    </div>
                </div>


            </div>
            <div class="mdui-divider"></div>

            @if (UserApp.IsUserHasButtonClaim(User, "SystemManage_User_Details_CanViewRelatedRoles"))
            {


                <div class="mdui-typo-title mdui-p-t-2">关联角色</div>
                <div class="mdui-list">

                @if (Model.Roles != null && Model.Roles.Count() > 0)
                {

                    foreach (var item in Model.Roles)
                    {
                <div class="mdui-list-item mdui-ripple">
                    <i class="mdui-list-item-icon mdui-icon material-icons">group</i>
                    <div class="mdui-list-item-content">
                        <div class="mdui-list-item-title">
                            @item.ShowName
                        </div>
                        @if (!string.IsNullOrEmpty(item.Description))
                        {
                            <div class="mdui-list-item-text">
                                @item.Description
                            </div>
                        }

                    </div>
                </div>
                    }


                }
                else
                {
                    <div class="mdui-list-item mdui-ripple">
                        <div class="mdui-list-item-content">
                            <div class="mdui-list-item-title">
                                <span class="mdui-text-color-theme-accent">当前用户未关联任何角色</span>
                            </div>
                        </div>
                    </div>
                }
            </div>
                <div class="mdui-divider"></div>
            }


            @if(UserApp.IsUserHasButtonClaim(User, "SystemManage_User_Details_CanViewRelatedStrategorys"))
            {

            
            <div class="mdui-typo-title mdui-p-t-2">关联策略</div>
            <div class="mdui-list">

                @if (Model.Strategorys != null && Model.Strategorys.Count() > 0)
                {

                    foreach (var item in Model.Strategorys)
                    {
                <div class="mdui-list-item mdui-ripple">
                    <i class="mdui-list-item-icon mdui-icon material-icons">lock_open</i>
                    <div class="mdui-list-item-content">

                        <div class="mdui-list-item-title">
                            @item.Name
                        </div>
                        @if (!string.IsNullOrEmpty(item.Description))
                        {
                            <div class="mdui-list-item-text">
                                @item.Description
                            </div>
                        }

                    </div>
                    @if (item.IsSuper == true)
                    {<div class="mdui-text-color-theme">超管策略</div>}
                </div>
                    }


                }
                else
                {
                    <div class="mdui-list-item mdui-ripple">
                        <div class="mdui-list-item-content">
                            <div class="mdui-list-item-title">
                                <span class="mdui-text-color-theme-accent">当前用户未关联任何策略</span>
                            </div>
                        </div>
                    </div>
                }
            </div>
            <div class="mdui-divider"></div>
            }

            <div class=" mdui-p-t-2"></div>
        </div>

        <div class="mdui-col-xs-12 mdui-col-md-6">
            @if (UserApp.IsUserHasButtonClaim(User, "SystemManage_User_Details_CanViewRelatedPermissions"))
            {

           
                <div class="mdui-typo-title mdui-p-t-4">关联权限</div>
            @if (Model.Strategorys.Any(x => x.IsSuper == true))
            {
                <p class="mdui-text-color-theme">关联策略中有超管策略，用户拥有全部权限。</p>
            }
            else
            {
                <tree-collapse-toggle items="@Model.Permissions" class="mdui-list" mdui-collapse></tree-collapse-toggle>
            }
            }
        </div>
    </div>
</div>
